package com.three.crm.adapter;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.three.crm.R;
import com.three.crm.bean.CommonBean;
import com.three.crm.util.AppManager;

import java.util.List;

public class OrderListAdapter extends BaseQuickAdapter<CommonBean, BaseViewHolder> {

    private String type = "";


    public void setType(String type) {
        this.type = type;
    }

    public OrderListAdapter(@Nullable List<CommonBean> data) {
        super(R.layout.item_list_order,data);
    }

    public OrderListAdapter() {
        super(R.layout.item_list_order);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, CommonBean item) {
        int approveStatus = item.getAdmin_status();
//        String adminNote = item.getAdmin_note();
//        String productNote = item.getProduct_upload_note();
//        int goodsUploadId = 0,feedbackId = 0;
//        goodsUploadId = item.getProduct_upload_id();
//        feedbackId = item.getFeedback_id();
//        boolean showUploadGoods = false,showFeedback = false;
//        int userType = AppManager.getLevel();
//        if (approveStatus == 1) {
//            if (userType == 1 || userType == 3) {
//                showUploadGoods = true;
//            }
//            if (userType == 2 && goodsUploadId > 0) {
//                showFeedback = true;
//            }
//        }

        helper.setText(R.id.tv_company,item.getTitle())
                .setText(R.id.tv_old_price, item.getPrice())
                .setText(R.id.tv_goods_name, "" + item.getGoods_name())
                .setText(R.id.tv_goods_num, "" + item.getGoods_num() + item.getGoods_unit())
                .setText(R.id.tv_price, "" + item.getMoney())
                .setText(R.id.tv_status, item.getAdmin_status_name())
                .setTextColor(R.id.tv_status,approveStatus == 0 ? mContext.getResources().getColor(R.color.black):approveStatus == 1 ? mContext.getResources().getColor(R.color.cor_green):mContext.getResources().getColor(R.color.redTab))
                .setText(R.id.tv_deal, item.getCar_time())
                .setText(R.id.tv_time, "" + item.getCtime())
                .setGone(R.id.tv_select,type.equals("select"))
                .setGone(R.id.tv_upload_goods,item.getCan_product_edit() == 1 ? true:false)
              //  .setText(R.id.tv_upload_goods, goodsUploadId != 0 ? "修改货量上传" :"新增货量上传")
                .setGone(R.id.tv_feedback,item.getCan_feedback_edit() == 1 ? true:false)
               // .setText(R.id.tv_feedback, feedbackId != 0 ? "修改质量反馈" :"新增质量反馈")
                .setGone(R.id.tv_upload_goods_detail,item.getCan_product_detail() == 1 ? true:false)
                .setGone(R.id.tv_feedback_detail,item.getCan_feedback_detail() == 1 ? true:false)
                .setGone(R.id.tv_edit,item.getCan_order_edit() == 1 ? true:false)
                .setGone(R.id.tv_detail,item.getCan_order_detail() == 1 ? true:false)
                .addOnClickListener(R.id.tv_detail,R.id.tv_edit,R.id.tv_select,R.id.tv_upload_goods,R.id.tv_feedback,R.id.tv_upload_goods_detail,R.id.tv_feedback_detail);
    }
}
